﻿<UserControl x:Class="IBTrader.Frontend.TestClient.Control"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:ctrlConn="clr-namespace:IBTrader.Frontend.Connection"
             xmlns:ctrlLog="clr-namespace:IBTrader.Frontend.Log"
             xmlns:my="clr-namespace:IBTrader.Frontend.TestClient"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="800">
    <UserControl.DataContext>
        <my:ViewModel/>
    </UserControl.DataContext>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding LoadedCommand}" 
                                   CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"/>
        </i:EventTrigger>
        <i:EventTrigger EventName="Closing" SourceObject="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">
            <i:InvokeCommandAction Command="{Binding UnloadedCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <DockPanel LastChildFill="True">
        <Menu DockPanel.Dock="Top" Height="22">
            <ctrlConn:Menu />
            <MenuItem Header="Order">
                <MenuItem Header="Place" Command="{Binding PlaceOrder}" />
                <MenuItem Header="Update" Command="{Binding UpdateOrder}" />
                <MenuItem Header="Cancel" Command="{Binding CancelOrder}" />
                <Separator/>
                <MenuItem Header="Request Open Orders" Command="{Binding RequestOpenOrders}" />
            </MenuItem>
            <MenuItem Header="Info">
                <MenuItem Header="Request Market Data" Command="{Binding RequestMarketData}" />
                <MenuItem Header="Cancel Market Data" Command="{Binding CancelMarketData}" />
                <Separator/>
                <MenuItem Header="Request Market Depth" Command="{Binding RequestMarketDepth}" />
                <MenuItem Header="Cancel Market Depth" Command="{Binding CancelMarketDepth}" />
                <Separator/>
                <MenuItem Header="Request Real Time Bars" Command="{Binding RequestRealTimeBars}" />
                <MenuItem Header="Cancel Real Time Bars" Command="{Binding CancelRealTimeBars}" />
                <Separator/>
                <MenuItem Header="Request Fundamental Data" Command="{Binding RequestFundamentalData}" />
                <MenuItem Header="Cancel Fundamental Data" Command="{Binding CancelFundamentalData}" />
                <Separator/>
                <MenuItem Header="Contract Details" Command="{Binding RequestContractDetails}" />
                <MenuItem Header="News Bulletins" Command="{Binding RequestNewsBulletins}" />
                <Separator/>
                <MenuItem Header="Account Updates" Command="{Binding RequestAccountUpdates}" />
            </MenuItem>
            <ctrlLog:Menu />
            <MenuItem Header="Download">
                <MenuItem Header="Executions" Command="{Binding ExportExecutions}"/>
                <MenuItem Header="Historical Data Seconds" Command="{Binding HistoricalSecondsRealtime}"/>
                <MenuItem Header="Historical Data Minutes" Command="{Binding HistoricalMinutesRealtime}"/>
                <MenuItem Header="Historical Data Seconds Extended Hours" Command="{Binding HistoricalSecondsExtended}"/>
                <MenuItem Header="Historical Data Minutes Extended Hours" Command="{Binding HistoricalMinutesExtended}"/>
                <MenuItem Header="Cancel" Command="{Binding CancelHistorical}"/>
            </MenuItem>
        </Menu>
        <ctrlLog:Status DockPanel.Dock="Bottom" Height="22" />
        <ScrollViewer Grid.Row="1">
            <StackPanel>
                <Expander IsExpanded="True">
                    <WrapPanel Orientation="Horizontal"  DockPanel.Dock="Top">
                        <ctrlConn:Control />
                        <GroupBox Header="Contract" >
                            <Grid VerticalAlignment="Top">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="90" />
                                </Grid.ColumnDefinitions>
                                <Label Content="Symbol:" Grid.Row="0"/>
                                <Label Content="SecurityType:" Grid.Row="1" />
                                <Label Content="Currency:" Grid.Row="2"/>
                                <TextBox Grid.Row="0" Grid.Column="1" Name="Symbol" Text="{Binding Path=Symbol, UpdateSourceTrigger=PropertyChanged}"/>
                                <ComboBox Grid.Row="1" Grid.Column="1" Name="SecurityType" SelectedIndex="0" Text="{Binding Path=SecurityType, UpdateSourceTrigger=PropertyChanged}">
                                    <ComboBoxItem Content="STK"/>
                                    <ComboBoxItem Content="OPT"/>
                                    <ComboBoxItem Content="FUT"/>
                                    <ComboBoxItem Content="IND"/>
                                    <ComboBoxItem Content="FOP"/>
                                    <ComboBoxItem Content="CASH"/>
                                    <ComboBoxItem Content="BAG"/>
                                    <ComboBoxItem Content="BOND"/>
                                </ComboBox>
                                <TextBox Grid.Row="2" Grid.Column="1" Name="Currency" Text="{Binding Path=Currency, UpdateSourceTrigger=PropertyChanged}"/>
                            </Grid>
                        </GroupBox>
                        <GroupBox Header="Contract Extended" >
                            <Grid VerticalAlignment="Top">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="90" />
                                </Grid.ColumnDefinitions>
                                <Label Content="Exchange:" Grid.Row="0"/>
                                <Label Content="Primary Exchange:" Grid.Row="1" />
                                <Label Content="Multiplier:" Grid.Row="2" />
                                <ComboBox Grid.Row="0" Grid.Column="1" Name="Exchange" IsEditable="True" Text="{Binding Path=Exchange, UpdateSourceTrigger=PropertyChanged}">
                                    <ComboBoxItem Content="SMART"/>
                                    <ComboBoxItem Content="NYMEX"/>
                                    <ComboBoxItem Content="GLOBEX"/>
                                </ComboBox>
                                <TextBox Grid.Row="1" Grid.Column="1" Name="PrimaryExchange" Text="{Binding Path=PrimaryExchange, UpdateSourceTrigger=PropertyChanged}"/>
                                <TextBox Grid.Row="2" Grid.Column="1" Name="Multiplier" Text="{Binding Path=Multiplier, UpdateSourceTrigger=PropertyChanged}"/>
                            </Grid>
                        </GroupBox>
                        <GroupBox Header="Contract Information" >
                            <Grid VerticalAlignment="Top">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="90" />
                                </Grid.ColumnDefinitions>
                                <Label Content="Bar Type:" Grid.Row="0"/>
                                <Label Content="Fundamental Data:" Grid.Row="1" />
                                <ComboBox Grid.Row="0" Grid.Column="1" Name="BarType" Text="{Binding Path=BarType, UpdateSourceTrigger=PropertyChanged}">
                                    <ComboBoxItem Content="TRADES"/>
                                    <ComboBoxItem Content="BID"/>
                                    <ComboBoxItem Content="ASK"/>
                                    <ComboBoxItem Content="MIDPOINT"/>
                                </ComboBox>
                                <ComboBox Grid.Row="1" Grid.Column="1" Name="FundamentalData" Text="{Binding Path=FundamentalData, UpdateSourceTrigger=PropertyChanged}">
                                    <ComboBoxItem Content="estimates"/>
                                    <ComboBoxItem Content="finstat"/>
                                    <ComboBoxItem Content="snapshot"/>
                                </ComboBox>
                            </Grid>
                        </GroupBox>
                        <GroupBox Header="Order" >
                            <Grid VerticalAlignment="Top">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="100" />
                                </Grid.ColumnDefinitions>
                                <Label Content="Action:" Grid.Row="0"/>
                                <Label Content="Type:" Grid.Row="1" />
                                <Label Content="Price:" Grid.Row="2"/>
                                <ComboBox Grid.Row="0" Grid.Column="1" Name="Action" SelectedIndex="0" Text="{Binding Path=Action, UpdateSourceTrigger=PropertyChanged}">
                                    <ComboBoxItem Content="BUY"/>
                                    <ComboBoxItem Content="SELL"/>
                                </ComboBox>
                                <ComboBox Grid.Row="1" Grid.Column="1" Name="OrderType" SelectedIndex="0" Text="{Binding Path=OrderType, UpdateSourceTrigger=PropertyChanged}">
                                    <ComboBoxItem Content="LMT"/>
                                    <ComboBoxItem Content="LMTCLS"/>
                                    <ComboBoxItem Content="MKT"/>
                                    <ComboBoxItem Content="MKTCLS"/>
                                    <ComboBoxItem Content="PEGMKT"/>
                                    <ComboBoxItem Content="REL"/>
                                    <ComboBoxItem Content="SCALE"/>
                                    <ComboBoxItem Content="STP"/>
                                    <ComboBoxItem Content="STPLMT"/>
                                    <ComboBoxItem Content="TRAIL"/>
                                    <ComboBoxItem Content="TRAILLIMIT"/>
                                    <ComboBoxItem Content="VWAP"/>
                                </ComboBox>
                                <TextBox Grid.Row="2" Grid.Column="1" Name="Price" Text="{Binding Path=Price, UpdateSourceTrigger=PropertyChanged}"/>
                            </Grid>
                        </GroupBox>
                        <GroupBox Header="Download">
                            <Grid VerticalAlignment="Top">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="100" />
                                </Grid.ColumnDefinitions>
                                <Label Content="From:" Grid.Row="0"/>
                                <Label Content="To:" Grid.Row="1" />
                                <DatePicker Grid.Row="0" Grid.Column="1" Name="DownloadFrom" SelectedDate="{Binding Path=DownloadFrom, UpdateSourceTrigger=PropertyChanged}"/>
                                <DatePicker Grid.Row="1" Grid.Column="1" Name="DownloadTo" SelectedDate="{Binding Path=DownloadTo, UpdateSourceTrigger=PropertyChanged}"/>
                            </Grid>
                        </GroupBox>
                    </WrapPanel>
                </Expander>
                <Expander Header="Log" IsExpanded="True">
                    <ctrlLog:Control />
                </Expander>
            </StackPanel>
        </ScrollViewer>
    </DockPanel>
</UserControl>
